﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ShareB.Models.NewPublicationModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	CreatePublication
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>CreatePublication</h2>

    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Fields</legend>

           
            <!-- Informação a preservar para o nosso modelo -->
            <%: Html.HiddenFor(model => model.UserID) %>
            <%: Html.HiddenFor(model => model.Username)%>
            <%: Html.HiddenFor(model => model.PubConfID)%>
            <%: Html.HiddenFor(model => model.StartDate)%>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.Tittle) %>

                <%: Html.TextBoxFor(model => model.Tittle) %>
                <%: Html.ValidationMessageFor(model => model.Tittle) %>
            </div>
            
            <% for (int i = 0; i < Model.configuration.fieldsConf.Count; i++)
               { %>
                    <div class="editor-field">
                        <%: Html.DisplayFor(model => model.configuration.fieldsConf[i].FieldName) %> : <!-- BRUTE FORCE SOLUTION -->
                        <%: Html.TextBoxFor(model => model.Fields[i].FieldValue) %>                        
                    </div>
                    <!-- Hidden fields to preserve information -->
                    <%: Html.HiddenFor(model => model.configuration.fieldsConf[i].FieldName)%>
                    <%: Html.HiddenFor(model => model.configuration.fieldsConf[i].FieldType)%>
                    <%: Html.HiddenFor(model => model.configuration.fieldsConf[i].MetaFieldID)%>
                    <%: Html.HiddenFor(model => model.Fields[i].FieldName)%>
                    <%: Html.HiddenFor(model => model.Fields[i].MetaFieldID)%>
            <% } %>

            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>

</asp:Content>

